import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:panda/base/Constant.dart';
import 'package:panda/base/application.dart';
import 'package:panda/main.dart';
import 'package:panda/set/BalanceRecord.dart';
import 'package:panda/set/DrawMoney.dart';

class MyYuePage extends StatefulWidget {
  MyYuePage({Key key}) : super(key: key);

  @override
  _MyYuePageState createState() => _MyYuePageState();
}

class _MyYuePageState extends State<MyYuePage> {
  String balance = "0.00";
  @override
  void initState() {
    super.initState();
    balance = APPLIC.userInfoMap['user_msg']['balance']==null?"0":APPLIC.userInfoMap['user_msg']['balance'];
    setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: f0Color,
      child: Column(
        children: <Widget>[
          Container(
            padding: EdgeInsets.fromLTRB(
                ScreenUtil.getInstance().setHeight(30),
                ScreenUtil.getInstance().setHeight(80),
                ScreenUtil.getInstance().setHeight(30),
                ScreenUtil.getInstance().setHeight(30)),
            color: mainColor,
            child: Row(
              children: <Widget>[
                GestureDetector(
                  child: Icon(
                    Icons.arrow_back_ios,
                    color: white,
                  ),
                  onTap: () {
                    Navigator.of(context).pop();
                  },
                  behavior: HitTestBehavior.opaque,
                ),
                Expanded(
                    child: Center(
                  child: Text(
                    '余额',
                    style: TextStyle(
                        color: white,
                        fontWeight: FontWeight.normal,
                        decoration: TextDecoration.none,
                        fontSize: ScreenUtil.getInstance().setSp(36)),
                  ),
                )),
                Icon(
                  Icons.arrow_back_ios,
                  color: mainColor,
                ),
              ],
            ),
          ),
          Stack(
            children: <Widget>[
              Container(
                height: MediaQuery.of(context).size.width / 4,
                color: mainColor,
              ),
              Container(
                width: MediaQuery.of(context).size.width,
                margin: EdgeInsets.fromLTRB(20, 0, 20, 0),
                decoration: BoxDecoration(
                    color: white, borderRadius: BorderRadius.circular(10)),
                padding: EdgeInsets.all(20),
                child: Column(
                  children: <Widget>[
                    Text(
                      '我的余额(元)',
                      style: TextStyle(
                          color: Colors.black87,
                          fontWeight: FontWeight.normal,
                          decoration: TextDecoration.none,
                          fontSize: ScreenUtil.getInstance().setSp(28)),
                    ),
                    Container(
                      height: 7,
                    ),
                    Text(
                      '$balance',
                      style: TextStyle(
                          color: Colors.black87,
                          fontWeight: FontWeight.normal,
                          decoration: TextDecoration.none,
                          fontSize: ScreenUtil.getInstance().setSp(45)),
                    ),
                    Container(
                      height: 25,
                    ),
                    GestureDetector(
                      child: Container(
                        decoration: BoxDecoration(
                          color: mainColor,
                          borderRadius: BorderRadius.circular(30),
                        ),
                        padding: EdgeInsets.fromLTRB(100, 5, 100, 5),
                        child: Text(
                          '提现',
                          style: TextStyle(
                              color: Colors.white,
                              fontWeight: FontWeight.normal,
                              decoration: TextDecoration.none,
                              fontSize: ScreenUtil.getInstance().setSp(30)),
                        ),
                      ),
                      onTap: () {
                        Navigator.of(context)
                            .push(new MaterialPageRoute(builder: (context) {
                          return DrawMoneyPage(total: balance);
                        }));
                      },
                      behavior: HitTestBehavior.opaque,
                    )
                  ],
                ),
              )
            ],
          ),
          GestureDetector(
            child: Container(
              decoration: BoxDecoration(
                color: white,
                borderRadius: BorderRadius.circular(10),
              ),
              width: MediaQuery.of(context).size.width,
              margin: EdgeInsets.all(15),
              padding: EdgeInsets.all(10),
              child: Row(
                children: <Widget>[
                  Expanded(
                      child: Text(
                    '余额明细',
                    style: TextStyle(
                        color: Colors.black87,
                        fontWeight: FontWeight.normal,
                        decoration: TextDecoration.none,
                        fontSize: ScreenUtil.getInstance().setSp(28)),
                  )),
                  Icon(
                    Icons.arrow_forward_ios,
                    color: Colors.grey,
                    size: 15,
                  )
                ],
              ),
            ),
            onTap: () {
              Navigator.of(context)
                  .push(new MaterialPageRoute(builder: (context) {
                return BalanceRecordPage();
              }));
            },
            behavior: HitTestBehavior.opaque,
          ),
         ],
      ),
    );
  }
}
